from core.basehandler import BaseHandler
from core.support import set_cutscene, get_game
from core.room import Room
from core.action import Action
from items.jellyfish import Jellyfish


class Deck(Room):
    def __init__(self, room_id):
        Room.__init__(self, room_id)    # do basic initialization for every room
        
        # add inventory items
        self.add_item(Jellyfish())
        
        # build list of actions
        self.add_action(Back)
        self.add_action(Nest)
        self.add_action(Hull)
    
    # return description of room.
    def get_description(self):
        return "You are standing in the deck of a 17th century pirate ship! Isn't it awesome?."
    
    # return image of room
    def get_image(self):
        return 'deck.jpg'


class DeckHandler(BaseHandler):
    
    # return class to use to create a new instance of this room
    def get_room_class(self):
        return Deck

# define actions for this room

class Back(Action):
    def __init__(self):
        Action.__init__(self, "Back")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go back"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        return 'sirens'
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"


class Nest(Action):
    def __init__(self):
        Action.__init__(self, "Nest")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go to the Crow's Nest"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        game = get_game()
        player = game.get_player()
        if 'scuba_suit' in player.inventory:
            return 'nest'
        else:
            return 'deck'
        

    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"
    
class Hull(Action):
    def __init__(self):
        Action.__init__(self, "Hull")    # do basic initialization for every action
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Go Downstairs"
    
    # return id of room to enter when action is complete
    def get_destination(self):
        game = get_game()
        player = game.get_player()
        if 'scuba_suit' in player.inventory:
            return 'hull'
        else:
            set_cutscene("You cannot go deeper without the scuba equipment.")
            return 'deck'
            
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "get"    